package volatileTest;

import java.util.concurrent.TimeUnit;

/**
 * @program: javase
 * @description: volatile 保证可见性
 * @author: lld
 * @create: 2021-04-22 21:59
 **/
public class Test1 {
    private static volatile int i=0;
    public static void main(String[] args) throws InterruptedException {

        new Thread(()->{
            while (i==0){
//                System.out.println("执行中");
            }
        }).start();
        TimeUnit.SECONDS.sleep(1);
        i=1;
    }
}
